package com.quan.system.rpc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Condition;

import com.quan.base.common.base.service.support.BaseService;
import com.quan.system.rpc.api.SysOssService;
import com.quan.system.rpc.dao.mapper.SysOssMapper;
import com.quan.system.rpc.model.SysOss;

@Service
public class SysOssServiceImpl extends BaseService<SysOss, Integer> implements SysOssService {
	
	@Autowired
	private SysOssMapper mapper ;

	@Override
	public int deleteByFileName(String filename) {
		Condition condition = new Condition(SysOss.class);
		condition.createCriteria().andEqualTo("fname", filename) ;
		return this.mapper.deleteByCondition(condition);
	}

	@Override
	public SysOss selectByFileName(String filename) {
		Condition condition = new Condition(SysOss.class);
		condition.createCriteria().andEqualTo("fname", filename) ;
		List<SysOss> list = this.mapper.selectByCondition(condition);
		if(null != list && !list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public SysOss selectByViewUrl(String viewUrl) {
		Condition condition = new Condition(SysOss.class);
		condition.createCriteria().andEqualTo("url", viewUrl) ;
		List<SysOss> list = this.mapper.selectByCondition(condition);
		if(null != list && !list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}
	
	

}
